package com.zx.platform.context;


import com.zx.platform.service.domain.DirectoryModel;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import java.io.IOException;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 14-3-8
 * Time: 下午2:41
 * To change this template use File | Settings | File Templates.
 */
public class GetDictCaptionELTag extends TagSupport {

    /**
     * 字典分类
     */
    protected String key;

    /**
     * value
     */
    protected String value;

    //执行
    public int doStartTag() throws JspException {
        String out = null;
        //字典上下文
        List<DirectoryModel> directoryModelList = DirectoryInfoContext.getDirectInfoList();
        for (DirectoryModel directoryModel : directoryModelList) {
            if (directoryModel.getDirKey().equals(key) && directoryModel.getDirValue().equals(value)) {
                out = directoryModel.getDirCaption();
            }
        }
        try {
            if (null != out) {
                pageContext.getOut().print(out);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        return SKIP_BODY;
    }

    //结果
    public int doEndTag() {
        //、、、、
        return EVAL_PAGE;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }
}